//
//  ViewController.m
//  星期一
//
//  Created by 来定MAC on 15/7/15.
//  Copyright (c) 2015年 LD. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

- (IBAction)click_test:(id)sender;
@property(nonatomic,strong)UIImageView *recommandView;

@end

@implementation ViewController

#pragma mark --lefe cycle Area
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationController.view addSubview:self.recommandView];
    
    UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click_recommandView:)];
    [[UIApplication sharedApplication].keyWindow addGestureRecognizer:tapGes];
    
    
    [self loadSubviewLayout];
}

- (void)loadSubviewLayout
{
    self.recommandView.translatesAutoresizingMaskIntoConstraints = NO;
    [[UIApplication sharedApplication].keyWindow addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[imageView]-0-|" options:0 metrics:nil views:@{@"imageView":self.recommandView}]];
    [[UIApplication sharedApplication].keyWindow addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[imageView]-0-|" options:0 metrics:nil views:@{@"imageView":self.recommandView}]];
    
    [UIView animateWithDuration:5 animations:^{
        self.recommandView.transform = CGAffineTransformMakeScale(1.2f, 1.2f);
        self.recommandView.alpha = 0.8;
    } completion:^(BOOL finished) {
        [self.recommandView removeFromSuperview];
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark --event action Area
- (void)click_recommandView:(UITapGestureRecognizer *)tapGes
{
//    NSLog(@"你已经点击了recommandView");
    [self.recommandView removeFromSuperview];
    tapGes.enabled = NO;
}
#pragma mark --lazy load Area
- (IBAction)click_test:(id)sender {
    
    UIViewController *vc = [[UIViewController alloc] init];
    [vc.view setBackgroundColor:[UIColor redColor]];
    [self.navigationController pushViewController:vc animated:YES];
}

- (UIImageView *)recommandView
{
    if (_recommandView == nil) {
        
        _recommandView = [[UIImageView alloc] init];
        _recommandView.image = [UIImage imageNamed:@"login_bg"];
        
    }
    return _recommandView;
}



@end
